using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Business;
using Entity;

public partial class CambiarPassword : BasePage
{
    #region Eventos
    protected void Page_Load(object sender, EventArgs e)
    {
        txtLogin.Focus();
        this.Title = Resources.Resource.lblPasswordPageName;
    }
    protected void btoGrabar_Click(object sender, EventArgs e)
    {
        try
        {
            String strLogin = txtLogin.Text.Trim();
            String strPasswordNuevo = txtPasswordNuevo.Text.Trim();
            String strPasswordAntiguo = txtPasswordActual.Text.Trim();

            UsuarioBO.ActualizarPassword(strLogin, Configuracion.CryptString(strPasswordNuevo), Configuracion.CryptString(strPasswordAntiguo));
            Cerrar();
        }
        catch (ManagerBusinessException)
        {
            ShowErrorMessageInAjax(UpdatePanelPassword);
        }
        catch (Exception ex)
        {
            Publish(ex, String.Empty);
            ShowErrorMessageInAjax(UpdatePanelPassword);
        }
    }
    protected void btoCancelar_Click(object sender, EventArgs e)
    {
        Cerrar();
    }
    #endregion

    #region Methods
    private void Cerrar()
    {
        ScriptManager.RegisterStartupScript(UpdatePanelPassword, GetType(), "Script", "self.close();", true);        
    }
    #endregion
}
